package com.ktc.base.service.serviceImpl;

import com.ktc.base.dao.LabelDao;
import com.ktc.base.entity.Label;
import com.ktc.base.service.LabelService;
import com.ktc.utils.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LabelServiceImpl implements LabelService {

    @Autowired
    private LabelDao labelDao;


    public void add(Label label) {
        //分布式id
        label.setId(IdUtil.nextId() + "");
        labelDao.save(label);
    }

    public void deleteById(String id) {
        labelDao.deleteById(id);
    }

    public void update(Label label) {
        labelDao.save(label);
    }

    public Label findById(String id) {
        return labelDao.findById(id).get();
    }

    public List<Label> findAll() {
        return labelDao.findAll();
    }
}


